<?php

/**
 * 抽奖
 * @author zhangyuxiong
 *
 */
class Lottery {
	//TODO - Insert your code here
	

	private $ip = '127.0.0.1';
	private $username;
	
	public function __construct($ip, $phone) {
		$this->ip = $ip;
		$this->phone = $phone;
	}
	
	public function LuckyDraw() {
		$t=$this->Rate();
		echo $t;
		return ($t==3);
	}
	
	private function Rate() {
		
		$rnd = rand ( 0, 1393 );
		$re = 0;
		if ($rnd == 0) {
			$re = 12;
		} else if ($rnd < 3) {
			$re = 11;
		} else if ($rnd < 12) {
			$re = 10;
		} else if ($rnd < 35) {
			$re = 9;
		} else if ($rnd < 71) {
			$re = 8;
		} else if ($rnd < 130) {
			$re = 7;
		} else if ($rnd < 212) {
			$re = 6;
		} else if ($rnd < 331) {
			$re = 5;
		} else if ($rnd < 567) {
			$re = 4;
		} else if ($rnd < 921) {
			$re = 3;
		} else {
			$re = 2;
		}
		
		return $re;
	}

}

?>